﻿/*
Digraph (library for building, traversal, comparison and saving of directed
graph).

Copyright (C) 2014 Dmitry Merzagitovich Arslanov

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option) any
later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*/

// How to save digraph in trivial graph format (tgf) file and load it back.
namespace Sample4
{
    // Define digraph types.
    using Vertex = Digraph.Vertex<string, string>;
    using Builder = Digraph.Builder<string, string>;

    public static class App
    {
        public static void Main()
        {
            // Create simple digraph.
            Builder builder = new Builder();
            Vertex vertex1 = builder.NewVertex("v1");
            Vertex vertex2 = builder.NewVertex("v2");
            builder.NewArc(vertex1, vertex2, "a");
            // Save digraph in file digraph.tgf
            builder.Digraph.Save("digraph.tgf");
            // Load digraph builder back and then use it.
            Builder loadedBuilder = Builder.Load("digraph.tgf");
        }
    }
}

#region Content of digraph.tgf is shown below in comments:
/*
1 v1
2 v2
#
1 2 a
*/
#endregion
